package smartlifev30.com.sdk.api.gateway_app;

import android.support.annotation.NonNull;

import smartlifev30.com.sdk.util.JsonUtil;
import smartlifev30.com.sdk.api.CallBack;
import smartlifev30.com.sdk.api.ConstantGateway;
import smartlifev30.com.sdk.bean.request.CfgVerQueryRequest;
import smartlifev30.com.sdk.bean.request.HardVerQueryRequest;
import smartlifev30.com.sdk.bean.request.RequestGwUpdateRequest;
import smartlifev30.com.sdk.bean.response.CfgVerQueryResponse;
import smartlifev30.com.sdk.net.baiwei.NetManager;

/**
 * Created by tys on 2018/8/15.
 */

public class VersionMgmtGatewayImpl implements IVersionMgmtGateway{

    @Override
    public void cfgVerQuery(@NonNull String userName, @NonNull String token, @NonNull String sn,
                            @NonNull CallBack<CfgVerQueryResponse> callBack){
        CfgVerQueryRequest cfgVerQueryRequest = new CfgVerQueryRequest();
        cfgVerQueryRequest.setFrom(userName);
        cfgVerQueryRequest.setTo(sn);
        cfgVerQueryRequest.setMsg_id(callBack.getMsgId());
        cfgVerQueryRequest.setMsg_class(ConstantGateway.MSG_CLASS_VERSION);
        cfgVerQueryRequest.setMsg_name("cfg_ver_query");
        cfgVerQueryRequest.setMsg_type(ConstantGateway.MSG_TYPE_GET);
        cfgVerQueryRequest.setToken(token);
        NetManager.getInstance().sendMessage(JsonUtil.toString(cfgVerQueryRequest));
    }

    @Override
    public void hardVerQuery(@NonNull String userName, @NonNull String token, @NonNull String sn, @NonNull CallBack<CfgVerQueryResponse> callBack) {
        HardVerQueryRequest hardVerQueryRequest = new HardVerQueryRequest();
        hardVerQueryRequest.setFrom(userName);
        hardVerQueryRequest.setTo(sn);
        hardVerQueryRequest.setMsg_id(callBack.getMsgId());
        hardVerQueryRequest.setMsg_class(ConstantGateway.MSG_CLASS_VERSION);
        hardVerQueryRequest.setMsg_name("hard_ver_query");
        hardVerQueryRequest.setMsg_type(ConstantGateway.MSG_TYPE_GET);
        hardVerQueryRequest.setToken(token);
        NetManager.getInstance().sendMessage(JsonUtil.toString(hardVerQueryRequest));
    }

    @Override
    public void requestGwUpdate(@NonNull String userName, @NonNull String token, @NonNull String sn, @NonNull CallBack<CfgVerQueryResponse> callBack) {
        RequestGwUpdateRequest requestGwUpdateRequest = new RequestGwUpdateRequest();
        requestGwUpdateRequest.setFrom(userName);
        requestGwUpdateRequest.setTo(sn);
        requestGwUpdateRequest.setMsg_id(callBack.getMsgId());
        requestGwUpdateRequest.setMsg_class(ConstantGateway.MSG_CLASS_VERSION);
        requestGwUpdateRequest.setMsg_name("request_gw_update");
        requestGwUpdateRequest.setMsg_type(ConstantGateway.MSG_TYPE_SET);
        requestGwUpdateRequest.setToken(token);
        NetManager.getInstance().sendMessage(JsonUtil.toString(requestGwUpdateRequest));
    }



}
